package Test10_7;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ServerThread extends Thread{
	static String hello = "From Server:Hello World!";
	Socket sock;
	public ServerThread(Socket s){
		sock = s;
	}
	public void run(){
		try{
			InputStream in = sock.getInputStream();
			DataInputStream din = new DataInputStream(in);
			String name = din.readUTF();
			OutputStream out = sock.getOutputStream();
			DataOutputStream dos = new DataOutputStream(out);
			dos.writeUTF(hello+"Your name:"+name);
			in.close();
			out.close();
			sock.close();
		}catch(IOException e){
			System.out.println(e);
		}
	}
}
